/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package csdwa;

import java.sql.Timestamp;
import java.util.Date;

/**
 * This class is used to represent the site when a user is logged on to it. It
 * is for use primarily with the user history recording.
 *
 * @author Anton Strack
 */
public class Site extends Resource implements CsdwaRecordable, CsdwaNotifiable {

    /**
     * The timestamp that the site object was created and thus accessed. This is
     * required for the user history functionality.
     */
    Timestamp time;
    /**
     * This is the current name for the Site object, it may or may not be the
     * name of the actual Site application.
     */
    private String name;

    /**
     * By default always set id to 0 and also set resource type to 0 The site
     * name defaults to the name of the site as setup in the Configuration
     * class.
     */
    public Site() {
        super(0, 0);
        this.time = new Timestamp(new Date().getTime());
        this.name = Configuration.getSiteName();
    }

    /**
     * By default always set id to 0. The site name defaults to the name of the
     * site as setup in the Configuration class.
     *
     * @param resourceTypeId the database defined resource id for the site.
     */
    public Site(int resourceTypeId) {
        super(0, resourceTypeId);
        this.time = new Timestamp(new Date().getTime());
        this.name = Configuration.getSiteName();
    }

    /**
     * This constructor allows for setting a differant value for the name. This
     * is intended to allow different names according to the site actions.
     * Primarily, the ability to record a search query or the future addition of
     * registering users or blocking them. By default always set id to 0 and
     * also set resource type to 0
     *
     * @param name the value to be used as the name.
     */
    public Site(String name) {
        super(0, 0);
        this.time = new Timestamp(new Date().getTime());
        this.name = name;
    }

    /**
     * This constructor allows for setting a differant value for the name. This
     * is intended to allow different names according to the site actions.
     * Primarily, the ability to record a search query or the future addition of
     * registering users or blocking them. By default always set id to 0
     *
     * @param resourceTypeId the database defined resource id for the site.
     * @param name the value to be used as the name.
     */
    public Site(int resourceTypeId, String name) {
        super(0, resourceTypeId);
        this.time = new Timestamp(new Date().getTime());
        this.name = name;
    }

    @Override
    public int getStateId() {
        return 0;
    }

    /**
     * Site doesn't have an updated or created date purpose. Just return the
     * current time as it reflects the time the site object is being used.
     *
     * @return
     */
    @Override
    public Timestamp getUpdatedDate() {
        return time;
    }

    @Override
    public Timestamp getCreatedDate() {
        return time;
    }

    @Override
    public String getName() {
        return this.name;
    }

    public void setName(String name) {
        this.name = name;
    }
}
